package dao.impl;

import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import dao.PictureDAO;
import domain.Picture;

/**
 * 图片Dao实现类.
 * <p>
 * 创建日期：2010-07-01<br>
 * 创建人：Xiyt<br>
 * 修改日期：<br>
 * 修改人：<br>
 * 修改内容：<br>
 * 
 * @author Xiyt
 * @version 1.0
 */
public class PictureDAOImpl extends SqlMapClientDaoSupport implements PictureDAO {

	 /**
     * 构造方法
     * @author xiyt
     */
    public PictureDAOImpl() {
        super();
    }
    
    /**
     * 根据主键查询对象
     * @param picture 对象
     * @author xiyt
     */
    public Picture selectByPrimaryKey(int id) {
        Picture record = (Picture) getSqlMapClientTemplate().queryForObject("an_picture.selectByPrimaryKey", id);
        return record;
    }
    
    /**
     * 根据条件查询对象列表
     * @param picture 对象
     * @author xiyt
     */
    @SuppressWarnings("unchecked")
	public List<Picture> selectByCriteria(Picture picture){
    	List<Picture> list = (List<Picture>)getSqlMapClientTemplate().queryForList("an_picture.selectByCriteria", picture);
        return list;
    }
    
    /**
     * 根据条件查询对象列表
     * @param picture 对象
     * @param start 开始行号
     * @param limit 每次查询行数
     * @author xiyt
     */
    @SuppressWarnings("unchecked")
	public List<Picture> selectByCriteriaForPaging(Picture picture, int start, int limit){
    	List<Picture> list = (List<Picture>)getSqlMapClientTemplate().queryForList("an_picture.selectByCriteria", picture, start, limit);
        return list;
    }
    
    /**
     * 根据条件查询对象个数
     * @param picture 查询条件对象
     * @author xiyt
     */
    public int countByCriteria(Picture picture){
    	Integer count = (Integer)  getSqlMapClientTemplate().queryForObject("an_picture.countByCriteria", picture);
        return count;
    }

    /**
     * 插入对象
     * @param picture 对象
     * @author xiyt
     */
    public void insert(Picture picture){
    	getSqlMapClientTemplate().insert("an_picture.insert", picture);
    }

    /**
     * 根据条件更新对象
     * @param picture 对象
     * @author xiyt
     */
    public int updateByPrimaryKey(Picture picture){
        int rows = getSqlMapClientTemplate().update("an_picture.updateByPrimaryKey", picture);
        return rows;
    }
    

    /**
     * 根据条件删除对象个数
     * @param picture 查询条件对象
     * @author xiyt
     */
    public int deleteByPrimaryKey(int id){
    	int rows = getSqlMapClientTemplate().delete("an_picture.deleteByPrimaryKey", id);
        return rows;
    }
}